﻿using System.ComponentModel.DataAnnotations;

namespace Wips.Domain.Models
{
    /// <summary>
    /// 发布流程
    /// </summary>
    [SugarTable("publish_flow")]
    public class PublishFlow : EntityBase, IAggregateRoot
    {
        /// <summary>
        /// 归属服务
        /// </summary>
        public string AgentServerConfigId { get; set; } = "";


        /// <summary>
        /// 
        /// </summary>
        [Navigate(NavigateType.OneToOne, nameof(AgentServerConfigId))]
        public AgentServerConfig? AgentServerConfig { get; set; }


        /// <summary>
        /// 归属服务器
        /// </summary>
        public string AgentServerId { get; set; } = "";

        /// <summary>
        /// 
        /// </summary>
        [Navigate(NavigateType.OneToOne, nameof(AgentServerId))]
        public AgentServer? AgentServer { get; set; }


        /// <summary>
        /// 发布流程名称 - 自动生成
        /// </summary>
        public string Name { get; set; } = "";

        /// <summary>
        /// 发布内容
        /// </summary>
        [MaxLength(500)]
        public string Context { get; set; } = "";


        /// <summary>
        /// 节点数据
        /// </summary>
        [SqlSugar.Navigate(SqlSugar.NavigateType.OneToMany, nameof(PublishFlowNode.PublishFlowId))]
        public List<PublishFlowNode>? Nodes { get; set; }


        /// <summary>
        /// 状态
        /// </summary>
        public EnumPublishFlowStatus? PublishFlowStatus { get; set; } = EnumPublishFlowStatus.None;
    }

    /// <summary>
    /// 状态
    /// </summary>
    public enum EnumPublishFlowStatus
    {
        /// <summary>
        /// 默认
        /// </summary>
        None = 1,

        /// <summary>
        /// 进行中
        /// </summary>
        Processing = 2,

        /// <summary>
        /// 取消
        /// </summary>
        Cancel = 3,

        /// <summary>
        /// 完成
        /// </summary>
        Finish = 4,


        /// <summary>
        /// 还原
        /// </summary>
        ReStore = 5
    }

}
